package com.db.test;

import com.db.pojo.Person;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class MongoDemo {

    @Autowired
    private MongoTemplate mongoTemplate;

    /**
     * 更新操作
     * 当id存在的时候，则执行修改
     *     	当id不存在的时候，则执行新增
     */
    @Test
    public void save(){
        Person person = new Person(1L,"张三",10);
        mongoTemplate.save(person);
    }
}
